package com.practice.reggie.service.impl.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.practice.reggie.entity.Dish;
import com.practice.reggie.entity.DishFlavor;
import com.practice.reggie.mapper.DishMapper;
import com.practice.reggie.service.DishFlavorService;
import com.practice.reggie.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class DishServiceImpl extends ServiceImpl<DishMapper, Dish> implements DishService {
    @Autowired
    private DishFlavorService dishFlavorService;
    /**
     * 批量删除
     * @param ids
     */
    @Override
    public void del(String[] ids) {
        LambdaQueryWrapper<DishFlavor> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(DishFlavor::getDishId,ids);
        //先删除口味表信息
        dishFlavorService.remove(wrapper);
        //删除主表信息
        List<String> strings = Arrays.asList(ids);
        removeByIds(strings);
    }
}
